package base.Day05;

import java.util.Random;

public class MethodDemo02
{
    public static void main(String[] args)
    {
        getSum(1, 3, 4);
        System.out.println(getSum(1, 3));
        int x = 10;
        int y = 11;
        int s = getSum(x, y);
        System.out.println(s);
        System.out.println("--------------------------------");
        int[] arr = generateArray(11);
        for (int a :
                arr)
        {
            System.out.println(a);
        }
    }

    public static int getSum(int num1, int num2)
    {
        return num1 + num2;
    }

    public static void getSum(int num1, int num2, int num3)
    {
        System.out.println("sum = " + (num1 + num2 + num3));    // 不加括号输出   sum= 134
        // 加括号输出  sum = 8
    }


    public static int[] generateArray(int size)
    {
        int[] arr = new int[size];
        for (int i = 0; i < size; i++)
            arr[i] = (int) (Math.random() * 100);
        return arr;
    }


    public static int[] generateArray(int size, int max)
    {
        // 重载
        int[] arr = new int[size];
        for (int i = 0; i < size; i++)
        {
            arr[i] = (int) (Math.random() * (max + 1));     //  0-99
        }
        return arr;
    }


    public static int[] generateArray1(int s, int m)
    {
        int[] arr = new int[s];
        for (int i = 0; i < s; i++)
        {
            arr[i] = new Random().nextInt(m + 1);
        }
        return arr;
    }

}
